import request from '@/api/request.js';

export function history(){
	return new Promise((resolve, reject) =>{
		request('/amount/history', 'GET')
		  .then((res) => {
		    resolve(res);
		  })
		  .catch((err) => {
		    reject(err);
		  });
	})
}

export function applyAmount(goods){
	return new Promise((resolve, reject) =>{
		request('/amount', 'POST',goods)
		  .then((res) => {
		    resolve(res);
		  })
		  .catch((err) => {
		    reject(err);
		  });
	})
}

export function instoreGoods(){
	return new Promise((resolve, reject) =>{
		request('/instore/goods', 'GET')
		  .then((res) => {
		    resolve(res);
		  })
		  .catch((err) => {
		    reject(err);
		  });
	})
}


export function loanGoods(){
	return new Promise((resolve, reject) =>{
		request('/amount/goods', 'GET')
		  .then((res) => {
		    resolve(res);
		  })
		  .catch((err) => {
		    reject(err);
		  });
	})
}


export function applyLoan(loan){
	return new Promise((resolve, reject) =>{
		request('/loan', 'POST',loan)
		  .then((res) => {
		    resolve(res);
		  })
		  .catch((err) => {
		    reject(err);
		  });
	})
}

export function loanProcess(){
	return new Promise((resolve, reject) =>{
		request('/loan/process', 'GET')
		  .then((res) => {
		    resolve(res);
		  })
		  .catch((err) => {
		    reject(err);
		  });
	})
}


export function loanRecord(){
	return new Promise((resolve, reject) =>{
		request('/loan/record', 'GET')
		  .then((res) => {
		    resolve(res);
		  })
		  .catch((err) => {
		    reject(err);
		  });
	})
}

export function loanDetail(id){
	return new Promise((resolve, reject) =>{
		request('/loan/'+id, 'GET')
		  .then((res) => {
		    resolve(res);
		  })
		  .catch((err) => {
		    reject(err);
		  });
	})
}

export function loanTotal(){
	return new Promise((resolve, reject) =>{
		request('/loan/total', 'GET')
		  .then((res) => {
		    resolve(res);
		  })
		  .catch((err) => {
		    reject(err);
		  });
	})
}